package leetcode.offer_two_special.queue;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author mazouri
 * @create 2021-09-11 16:30
 */
public class RecentCounter {
    Queue<Integer> queue;

    public RecentCounter() {
        queue = new LinkedList<>();
    }

    public int ping(int t) {
        queue.offer(t);
        while (queue.peek() + 3000 < t) queue.poll();

        return queue.size();
    }
}
